import { get, 
lsSetStr,
lsGetStr,post} from "../../utils/request.js";
var { getLoginedUser, 

fnLoading, fnHideLoading, fnSuccess, fnFail } = require('../../utils/index')
import _ from '../../utils/underscore.js';
//获取应用实例
const app = getApp()
Page({
  
    /**
     * 页面的初始数据
     */
    data: {
      couponsBg: false,
      other:[]
    },
  know: function (e) {
    if (e.currentTarget.dataset.id == '14229'){
      var typeId = '980'
      
    }else{
      var typeId = '981'
    }
    wx.navigateTo({
      url: '../../pages/DetailPags/index?id=' + typeId,

    })
  },

    onLoad: function (options) {
        let that = this;
        wx.showShareMenu();//
        wx.hideTabBar();
        app.customTabBar()
      if (options.partnerId){ //合伙人分享
        lsSetStr('partnerId', options.partnerId);//合伙人ID
      }
      
      if (options.shareId && options.no && options.type1){ //通过分享进入系统
        //fnFail(JSON.stringify(options)+'111');
        post({

          path: '/commission/shareGetRedEnvelope',
          data: {
            saleId: options.shareId,
            type1: options.type1,//11软著，12高企，13双软
            commission: (Math.random() + '').substr(0, 4),//随机红包
            no: options.no,
          }
        })
        }
        Promise.all([
            get({
            path: '/category1/list?type1=330&isShow=1&sortField=order_num&sortOrder=ASC'
            }),
            // get({
            //   path:"info/detail/980"
            // }),
            // get({
            //   path: "info/detail/981"
            // }),
          
        ])
            .then(function (res) {
                that.setData({
                  other: _.sortBy(res[0].slice(1,3),'id'),
                  // problem:res[1],
                })
            })
            .catch(function (res) {
                fnLoading("请求失败")
            })
      ;
      //获取登录登录用户信息
      getLoginedUser()
        .then(function (user) {
          that.setData({
            options: options,
            loginBgFlag: false
          })
        })
        .catch(function(e){
          if (e=='未登录'){
            that.setData({
              options: options,
              loginBgFlag: true
            })
          }
          console.log(e);//
        })
    },
    onShow()
    {
        // checkCoupon();
    },
    onShare(){}
})
